home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Modules / cryptmodule.c < prev    next >
C/C++ Source or Header  |  1998-12-25  |  856b  |  54 lines

  1. /* cryptmodule.c - by Steve Majewski
  2.  */
  3.  
  4. #include "Python.h"
  5.  
  6. #include <sys/types.h>
  7.  
  8. #ifdef AMITCP
  9. #include <proto/usergroup.h>
  10. #endif
  11. #ifdef INET225
  12. #include <proto/socket.h>
  13. static __inline STRPTR crypt(STRPTR pw, STRPTR un)
  14. {
  15.     static char buf[32];
  16.     return s_crypt(buf,pw,un);
  17. }
  18. #endif
  19.  
  20. #include "protos/cryptmodule_protos.h"
  21.  
  22. /* Module crypt */
  23.  
  24.  
  25. static PyObject *crypt_crypt(self, args)
  26.     PyObject *self, *args;
  27. {
  28.     char *word, *salt; 
  29.     extern char * crypt();
  30.  
  31.     if (!PyArg_Parse(args, "(ss)", &word, &salt)) {
  32.         return NULL;
  33.     }
  34.     return PyString_FromString( crypt( word, salt ) );
  35.  
  36. }
  37.  
  38. static PyMethodDef crypt_methods[] = {
  39.     {"crypt",    crypt_crypt},
  40.     {NULL,        NULL}        /* sentinel */
  41. };
  42.  
  43. void
  44. initcrypt()
  45. {
  46. #ifdef AMITCP
  47.     if(!checkusergrouplib()) return;
  48. #endif
  49. #ifdef INET225
  50.     if(!checksocketlib()) return;
  51. #endif
  52.     Py_InitModule("crypt", crypt_methods);
  53. }
  54.